home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Programming / SWI / source / src / configure.in < prev    next >
Encoding:
Text File  |  1998-04-15  |  16.8 KB  |  680 lines

  1. dnl Process this file with autoconf to produce a configure script.
  2.  
  3. AC_INIT(pl-wam.c)
  4.  
  5. AC_CONFIG_HEADER(config.h)
  6. AC_SUBST(PLBASE)
  7. AC_SUBST(STATICLIBS)
  8. AC_SUBST(COFLAGS)
  9. AC_SUBST(CWFLAGS)
  10. AC_SUBST(CMFLAGS)
  11. AC_SUBST(CIFLAGS)
  12. AC_SUBST(AR)
  13. AC_SUBST(ETAGS)
  14. AC_SUBST(LDFLAGS)
  15. AC_SUBST(STATICLIBS)
  16. AC_SUBST(ARCH)
  17. AC_SUBST(PLFOREIGN)
  18. AC_SUBST(PL)
  19. AC_SUBST(RT)
  20. AC_SUBST(PLVERSION)
  21. AC_SUBST(VPATH)
  22. AC_SUBST(COUTOPT)
  23. AC_SUBST(INSTALLTARGET)
  24.  
  25. INSTALLTARGET=dv-install
  26. PL=pl
  27. RT=""
  28. PLVERSION=`cat ../VERSION`
  29.  
  30. dnl ****************************************************************
  31. dnl Some systems don't appear to have true.  Hope all like this ...
  32. dnl ****************************************************************
  33.  
  34. true()
  35. { test a = a
  36. }
  37.  
  38. AC_PROG_CC
  39. AC_PROG_RANLIB
  40. AC_CANONICAL_HOST
  41. changequote(,)dnl
  42. ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)/\1-\2/'`
  43. changequote([,])dnl
  44.  
  45. AC_ARG_ENABLE(syslibh, [  --enable-syslibh      Prototype file to enable gcc -Wall],
  46.           [case "$enableval" in
  47.               yes)    AC_DEFINE(SYSLIB_H, "syslib.h")
  48.             syslibh=yes ;;
  49.           no)   ;;
  50.           *)    AC_DEFINE(SYSLIB_H, "$enableval")
  51.             syslibh=yes ;;
  52.           esac])
  53.  
  54. AC_ARG_ENABLE(runtime, [  --enable-runtime      Runtime system only],
  55.           [case "$enableval" in
  56.            yes) AC_DEFINE(O_RUNTIME)
  57.                 runtime=yes
  58.             RT=rt
  59.             INSTALLTARGET=rt-install ;;
  60.            *)  ;;
  61.            esac])
  62.  
  63.  
  64. dnl ****************************************************************
  65. dnl Checking for GNU make vpath construct
  66. dnl ****************************************************************
  67.  
  68. AC_CHECK_PROGS(MAKE, make gmake, "make")
  69. AC_MSG_CHECKING("whether make is GNU-make")
  70. if ($MAKE -v 2>&1) | grep GNU > /dev/null; then
  71.     AC_MSG_RESULT(yes)
  72.     VPATH="vpath %.c"
  73. else
  74.     VPATH="VPATH = "
  75.     AC_MSG_RESULT(no)
  76. fi
  77.  
  78. dnl ****************************************************************
  79. dnl Finding various programs
  80. dnl ****************************************************************
  81.  
  82. AC_CHECK_PROG(AR, ar, ar, ar)
  83. AC_CHECK_PROGS(ETAGS, etags ctags, ":")
  84. AC_PROG_AWK
  85. AC_PROG_INSTALL
  86. case "$INSTALL" in
  87.     ./*) if test -z "$PWD"; then PWD=`pwd`; fi
  88.          INSTALL="$PWD/$INSTALL" ;;
  89. esac
  90. AC_PROG_CPP
  91. AC_ISC_POSIX
  92. AC_HEADER_STDC
  93. if test "$GCC" = "yes"; then
  94.     COFLAGS=-O2
  95.     if test "$ac_cv_header_stdc" = "yes" || test "$syslibh" = "yes"; then
  96.         CWFLAGS=-Wall
  97.     else
  98.     CWFLAGS=
  99.     fi
  100.     CMFLAGS=-funsigned-char
  101. else
  102.     COFLAGS=-O
  103.     CWFLAGS=
  104.     CMFLAGS=
  105. fi
  106. CFLAGS="$CMFLAGS"
  107. AC_C_INLINE
  108. AC_FUNC_ALLOCA
  109. AC_C_BIGENDIAN
  110.  
  111. dnl ****************************************************************
  112. dnl Finding libraries
  113. dnl ****************************************************************
  114.  
  115. AC_CHECK_LIB(m, main)
  116. AC_CHECK_LIB(termcap, main)
  117. if test "$ac_cv_lib_termcap_main" = "yes"; then
  118.   AC_MSG_CHECKING("whether -ltermcap needs -lucb")
  119.   AC_TRY_LINK([],
  120.           [ tgetent();
  121.           ],
  122.           AC_MSG_RESULT(no)
  123.           true,
  124.           AC_MSG_RESULT(maybe ...)
  125.           checkucb=yes)
  126. else
  127.   AC_CHECK_LIB(ncurses, main)
  128.   if test ! "$ac_cv_lib_ncurses_main" = "yes"; then
  129.     AC_CHECK_LIB(curses, main)
  130.   fi
  131. fi
  132. if test "$checkucb" = "yes"; then
  133.     AC_CHECK_LIB(ucb, rindex)
  134. fi
  135. if test ! "$runtime" = "yes"; then
  136.   AC_CHECK_LIB(readline, main)
  137.   if test ! "$ac_cv_lib_readline_main" = "yes"; then
  138.     AC_CHECK_LIB(ncurses, main)
  139.     if test ! "$ac_cv_lib_ncurses_main" = "yes"; then
  140.       AC_CHECK_LIB(curses, main)
  141.     fi
  142.     if test "$ac_cv_lib_ncurses_main" = "yes" || test "$ac_cv_lib_curses_main" = "yes"; then
  143.       echo "Found curses library.  See if -lreadline works now"
  144.       unset ac_cv_lib_readline_main
  145.       AC_CHECK_LIB(readline, main)
  146.     fi
  147.   fi
  148. fi
  149. AC_ARG_ENABLE(shared, [  --disable-shared      No shared-lib interface],
  150.           configshared="$enableval",
  151.           configshared=yes)
  152. AC_ARG_ENABLE(save, [  --enable-save          Provide save/1 and friends],
  153.           configsave="$enableval",
  154.           configsave=no)
  155.  
  156. if test "$configsave" = "yes"; then
  157.     AC_CHECK_LIB(elf, main)
  158. fi
  159. if test "$configshared" = "yes"; then
  160.   AC_CHECK_LIB(dl, dlopen)
  161.   AC_CHECK_LIB(dld, shl_load)
  162.   AC_CHECK_FUNCS(dlopen)
  163.   AC_CHECK_FUNCS(shl_load)
  164. fi
  165.  
  166. if test "$ac_cv_func_dlopen" = "yes" || \
  167.    test "$ac_cv_func_shl_load" = "yes"; then
  168.   configloadforeign=no
  169.  
  170. AC_MSG_CHECKING(for cc -c -o)
  171.   cat > conftest.c << _EOP_
  172. main()
  173. { exit(0);
  174. }
  175. _EOP_
  176.   if ${CC-cc} $CFLAGS -c conftest.c -o conftest.o 1>&5 2>&5 && test -r conftest.o; then
  177.     COUTOPT='-o $@'
  178.     AC_MSG_RESULT(yes)
  179.   else
  180.     COUTOPT=
  181.     AC_MSG_RESULT(no)
  182.   fi
  183.   rm -rf conftest.*
  184.  
  185. dnl Some versions of (g)cc need to export the symbols from the main program
  186. dnl using -export-dynamic or (older versions) -rdynamic.  See whether
  187. dnl this gcc understands this flag.
  188.  
  189. AC_MSG_CHECKING("whether LDFLAGS need -export-dynamic")
  190.   old_ldflags="$LDFLAGS"
  191.   LDFLAGS="-export-dynamic $LDFLAGS"
  192.   AC_TRY_RUN(
  193. main()
  194. { exit(0);
  195. },
  196.      if grep 'unrecognized option `-export-dynamic'"'" config.log >/dev/null; then
  197.        AC_MSG_RESULT(no)
  198.        LDFLAGS="$old_ldflags"
  199.      else
  200.        AC_MSG_RESULT(yes)
  201.        exportdynamic=done
  202.      fi,
  203.      AC_MSG_RESULT(no)
  204.      LDFLAGS="$old_ldflags",
  205.      AC_MSG_RESULT(no)
  206.      LDFLAGS="$old_ldflags")
  207.  
  208. if test "$exportdynamic" != "done"; then
  209. AC_MSG_CHECKING("whether LDFLAGS need -rdynamic")
  210.   old_ldflags="$LDFLAGS"
  211.   LDFLAGS="-rdynamic $LDFLAGS"
  212.   AC_TRY_RUN(
  213. main()
  214. { exit(0);
  215. },
  216.      if grep 'unrecognized option `-rdynamic'"'" config.log >/dev/null; then
  217.        AC_MSG_RESULT(no)
  218.        LDFLAGS="$old_ldflags"
  219.      else
  220.        AC_MSG_RESULT(yes)
  221.      fi,
  222.      AC_MSG_RESULT(no)
  223.      LDFLAGS="$old_ldflags",
  224.      AC_MSG_RESULT(no)
  225.      LDFLAGS="$old_ldflags")
  226. fi
  227. else
  228.   configloadforeign=yes
  229. fi
  230.  
  231. echo "    LIBS=$LIBS"
  232.  
  233. AC_CHECK_HEADERS(unistd.h string.h memory.h sys/time.h sys/stat.h pwd.h)
  234. AC_CHECK_HEADERS(sys/select.h sys/param.h sys/file.h sys/resource.h malloc.h)
  235. AC_CHECK_HEADERS(sys/termios.h sys/termio.h bstring.h)
  236. AC_CHECK_HEADERS(mach-o/rld.h)
  237.  
  238. AC_CHECK_FUNCS(access chmod dossleep fstat readlink getwd getcwd getdtablesize)
  239. AC_CHECK_FUNCS(getpagesize getpwnam getrlimit gettimeofday opendir sysconf)
  240. AC_CHECK_FUNCS(popen putenv random remove rename rl_insert_close select)
  241. AC_CHECK_FUNCS(signal sigset sleep srand srandom stat strerror tgetent times)
  242. AC_CHECK_FUNCS(memmove stricmp strlwr sigaction sigsetmask siggetmask sigblock)
  243. AC_CHECK_FUNCS(rint aint floor ceil isnan tcsetattr cfmakeraw)
  244. AC_HEADER_TIME
  245. AC_HEADER_DIRENT
  246. AC_HEADER_SYS_WAIT
  247. AC_FUNC_VFORK
  248.  
  249. AC_MSG_CHECKING("alignment restrictions on doubles")
  250. AC_TRY_RUN(
  251. [ main()
  252.   { long l[10];
  253.     double *p;
  254.     unsigned long x = (unsigned long) l;
  255.  
  256.     if ( x % sizeof(double) == 0 )
  257.       x += sizeof(long);
  258.     p = (double  *) x;
  259.     *p = 1.0;
  260.  
  261.     exit(0);
  262.   }
  263. ],
  264. AC_MSG_RESULT(as long),
  265. AC_MSG_RESULT(sizeof(double))
  266. AC_DEFINE(DOUBLE_ALIGNMENT, sizeof(double)),
  267. AC_MSG_RESULT(assuming sizeof(double))
  268. AC_DEFINE(DOUBLE_ALIGNMENT, sizeof(double)))
  269.  
  270. if test "$ac_cv_func_getrlimit" = "yes"; then
  271. AC_MSG_CHECKING("type rlim_t")
  272. AC_TRY_COMPILE(
  273. [
  274. #include <sys/types.h>
  275. #include <sys/resource.h>
  276. ],
  277. [ rlim_t datasize;
  278. ], AC_DEFINE(HAVE_RLIM_T)
  279.    AC_MSG_RESULT(yes),
  280.    AC_MSG_RESULT(no))
  281. fi
  282.  
  283. AC_MSG_CHECKING("whether assert.h needs stdio.h")
  284. AC_TRY_COMPILE(
  285. [
  286. #include <assert.h>
  287. ],
  288. [ assert(1);
  289. ], AC_MSG_RESULT(no),
  290.    AC_MSG_RESULT(yes);
  291.    AC_DEFINE(ASSERT_H_REQUIRES_STDIO_H))
  292.  
  293. AC_CHECKING("for including sys/ioctl.h after sys/termios.h")
  294. if test "$GCC" = "yes"; then
  295.     ac_oldcflags="$CFLAGS"
  296.     CFLAGS="$CFLAGS -Werror"
  297. fi
  298. AC_TRY_COMPILE(
  299. [
  300. #include <stdio.h>
  301. #include <sys/types.h>
  302. #include <sys/termios.h>
  303. #include <sys/ioctl.h> 
  304. ],
  305. [;
  306. ], true, AC_DEFINE(NO_SYS_IOCTL_H_WITH_SYS_TERMIOS_H))
  307. if test "$GCC" = "yes"; then CFLAGS="$ac_oldcflags"; fi
  308.  
  309. if test -z "$ac_cv_header_sys_termio_h" -a -z "$ac_cv_header_sys_termios_h"; then
  310. AC_MSG_CHECKING("struct sgttyb")
  311. AC_TRY_COMPILE(
  312. [
  313. #include <sys/types.h>
  314. #include <sys/ioctl.h>
  315. ],
  316. [ struct sgttyb buf;
  317.   ;
  318. ], AC_DEFINE(HAVE_SGTTYB)
  319.    AC_MSG_RESULT(yes),
  320.    AC_MSG_RESULT(no))
  321. fi
  322.  
  323.  
  324. AC_MSG_CHECKING("for type uchar")
  325. AC_TRY_COMPILE(
  326. [
  327. #include <sys/types.h>
  328. typedef unsigned char uchar;
  329. ],
  330. [;], AC_DEFINE(NEED_UCHAR)
  331.      AC_MSG_RESULT("need typedef uchar"),
  332.      AC_MSG_RESULT("uchar predefined"))
  333.  
  334. AC_MSG_CHECKING("whether we need extern int errno")
  335. AC_TRY_COMPILE(
  336. [
  337. #include <sys/types.h>
  338. #include <stdio.h>
  339. #include <errno.h>
  340. ],
  341. [ return errno;
  342. ], AC_MSG_RESULT(no),
  343.    AC_DEFINE(NEED_DECL_ERRNO)
  344.    AC_MSG_RESULT(yes))
  345.  
  346. AC_MSG_CHECKING("for symbolic links")
  347. if touch conftest.x && ln -s conftest.x conftest.lns && cmp conftest.x conftest.lns; then
  348.     AC_DEFINE(HAVE_SYMLINKS)
  349.     AC_MSG_RESULT(yes)
  350. else
  351.     AC_MSG_RESULT(no)
  352. fi
  353.  
  354. AC_TYPE_SIGNAL
  355. AC_MSG_CHECKING("for BSD signal handlers")
  356. AC_TRY_RUN(
  357. [
  358. #include <stdio.h>
  359. #include <sys/types.h>
  360. #include <sys/stat.h>
  361. #include <signal.h>
  362. #ifdef HAVE_UNISTD_H
  363. #include <unistd.h>
  364. #endif
  365. static int signalled;
  366. static RETSIGTYPE catch (s) int s; { signalled = 1; }
  367. main()
  368. { signal(SIGINT, catch);
  369.   kill(getpid(), SIGINT);
  370.   while(!signalled)
  371.     ;
  372.   if ( signal(SIGINT, catch) == catch )
  373.     exit(0);
  374.   exit(1);
  375. }], AC_DEFINE(BSD_SIGNALS)
  376.     AC_MSG_RESULT("BSD signals"),
  377.     AC_MSG_RESULT("Posix signals"),
  378.     AC_MSG_RESULT("assuming Posix signals"))
  379.  
  380. AC_MSG_CHECKING("for SIGPROF profiler support")
  381. AC_TRY_RUN([
  382. #ifdef TIME_WITH_SYS_TIME
  383. #include <sys/time.h>
  384. #include <time.h>
  385. #else
  386. #ifdef HAVE_SYS_TIME_H
  387. #include <sys/time.h>
  388. #else
  389. #include <time.h>
  390. #endif
  391. #endif
  392. #include <signal.h>
  393. static RETSIGTYPE prof(s) int s; {exit(0);}
  394. main()
  395. { struct itimerval value, ovalue;
  396.   int n;
  397.   value.it_interval.tv_sec  = 0;
  398.   value.it_interval.tv_usec = 1;
  399.   value.it_value.tv_sec  = 0;
  400.   value.it_value.tv_usec = 1;
  401.   
  402.   signal(SIGPROF, prof);
  403.  
  404.   if (setitimer(ITIMER_PROF, &value, &ovalue) != 0)
  405.     exit(1);
  406.  
  407.   for(n=0; n<10000000; n++)
  408.     ;
  409.   exit(1);
  410. }], AC_DEFINE(O_PROFILE)
  411.     AC_MSG_RESULT(yes),
  412.     AC_MSG_RESULT(no),
  413.     true)
  414.  
  415. AC_MSG_CHECKING("for union wait")
  416. if test "$GCC" = yes; then
  417.     ac_oldcflags="$CFLAGS"
  418.     CFLAGS="$CFLAGS -Werror"
  419. fi
  420. AC_TRY_COMPILE(
  421. [
  422. #include <sys/wait.h>
  423. ],
  424. [ union wait status;
  425.   waitpid(1, &status, WNOHANG);
  426. ], AC_DEFINE(UNION_WAIT)
  427.    AC_MSG_RESULT(yes),
  428.    AC_MSG_RESULT(no))
  429. if test "$GCC" = "yes"; then CFLAGS="$ac_oldcflags"; fi
  430.  
  431. AC_MSG_CHECKING("for tagged lvalues")
  432. AC_TRY_COMPILE(
  433. [
  434. ],
  435. [ int x;
  436.   *(char *)&x = 'a';
  437.   exit(0);
  438. ], AC_DEFINE(TAGGED_LVALUE)
  439.    AC_MSG_RESULT(yes),
  440.    AC_MSG_RESULT(no))
  441.  
  442.  
  443. dnl ****************************************************************
  444. dnl Very specific SWI-Prolog tests.  First of all, we'll try to determine
  445. dnl the direction of the C-stack as well as the area where malloc()'ed data
  446. dnl lifes.  We run test/memmodel.c for this.
  447. dnl ****************************************************************
  448.  
  449. AC_MSG_CHECKING("memory model");
  450. echo '#include "confdefs.h"' > conftest.c
  451. cat $srcdir/test/memmodel.c >> conftest.c
  452. (eval $ac_link) 2>&5
  453. if test -s conftest && eval `./conftest`; then
  454.     AC_DEFINE_UNQUOTED(STACK_DIRECTION, $STACK_DIRECTION)
  455.     AC_MSG_RESULT(yes)
  456. else
  457.     AC_MSG_WARN("Failed to compile test/memmodel.c")
  458. fi
  459. rm -fr conftest*
  460.  
  461. dnl ****************************************************************
  462. dnl Test whether we can use asm("nop") to separate instructions.
  463. dnl Needed for gcc version 2 (see pl-wam.c)
  464. dnl ****************************************************************
  465.  
  466. AC_MSG_CHECKING("for nop");
  467. echo '#include "confdefs.h"' > conftest.c
  468. cat $srcdir/test/nop.c >> conftest.c
  469. (eval $ac_link) 2>&5
  470. if test -s conftest && eval `./conftest`; then
  471.     AC_MSG_RESULT(yes)
  472. else
  473.     AC_DEFINE(NO_ASM_NOP)
  474.     AC_MSG_RESULT(no)
  475. fi
  476. rm -fr conftest*
  477.  
  478.  
  479. dnl ****************************************************************
  480. dnl More tricky stuff.  Try to find out whether or not we can use mmap()
  481. dnl to implement dynamic stacks.  This requires mmap(), support for
  482. dnl `fixed' and `private' maps and support to map in the same area as
  483. dnl malloc() does.  The program map/mmap.c tests all these things.
  484. dnl ****************************************************************
  485.  
  486. AC_MSG_CHECKING("if we can use mmap for stack allocation")
  487. echo '#include "confdefs.h"' > conftest.c
  488. cat $srcdir/test/mmap.c >> conftest.c
  489. (eval $ac_link) 2>&5
  490. if test -s conftest && eval `./conftest`; then
  491.     if test "$MMAP_STACK" = "1"; then
  492.         if test "$HAVE_MAP_ANON" = "1"; then
  493.         AC_DEFINE(HAVE_MAP_ANON)
  494.         AC_MSG_RESULT("Using MAP_ANON")
  495.     else
  496.         AC_MSG_RESULT("Using MAP_PRIVATE")
  497.     fi
  498.         AC_DEFINE(MMAP_STACK)
  499.     else
  500.     AC_MSG_RESULT("mmap is not good enough")
  501.     fi
  502.     if test ! -z "$MMAP_MIN_ADDRESS"; then
  503.     AC_DEFINE_UNQUOTED(MMAP_MIN_ADDRESS, $MMAP_MIN_ADDRESS)
  504.     fi
  505.     if test ! -z "$MMAP_MAX_ADDRESS"; then
  506.     AC_DEFINE_UNQUOTED(MMAP_MAX_ADDRESS, $MMAP_MAX_ADDRESS)
  507.     fi
  508.     if test "$SIGNAL_HANDLER_PROVIDES_ADDRESS" = "1"; then
  509.     AC_DEFINE(SIGNAL_HANDLER_PROVIDES_ADDRESS)
  510.     fi
  511.     if test ! -z "$TOPOFHEAP"; then
  512.     AC_DEFINE_UNQUOTED(TOPOFHEAP, $TOPOFHEAP)
  513.     fi
  514. else
  515.     AC_MSG_RESULT("could not compile mmap test");
  516. fi
  517. rm -fr conftest*
  518.  
  519. if test "$configsave" = "yes"; then
  520.  
  521. dnl ****************************************************************
  522. dnl The real thing.  See whether we can use save/1 and friends.  The
  523. dnl hardest part is to find the start of the data segment.
  524. dnl ****************************************************************
  525.  
  526. AC_MSG_CHECKING("_data_start")
  527. AC_TRY_LINK([extern int _data_start;],
  528.         [ { int *x = &_data_start; }
  529.         ],
  530.         AC_DEFINE(FIRST_DATA_SYMBOL, _data_start)
  531.         AC_MSG_RESULT(yes),
  532.         AC_MSG_RESULT(no))
  533. AC_MSG_CHECKING("_data")
  534. AC_TRY_LINK([extern int _data;],
  535.         [ { int *x = &_data; }
  536.         ],
  537.         AC_DEFINE(FIRST_DATA_SYMBOL, _data)
  538.         AC_MSG_RESULT(yes),
  539.         AC_MSG_RESULT(no))
  540.  
  541. AC_MSG_CHECKING("whether we can get save/1 to work")
  542. echo '#include "confdefs.h"' > conftest.c
  543. echo '#define CONFTEST 1' >> conftest.c
  544. echo '#define TEST 1' >> conftest.c
  545. cat $srcdir/pl-save.c >> conftest.c
  546. ac_oldcflags="$CFLAGS"
  547. CFLAGS="-I$srcdir $CFLAGS"
  548. (eval $ac_link) 2>&5
  549. CFLAGS="$ac_oldcflags"
  550. if test -s conftest && ./conftest -s conftest.save >/dev/null && ./conftest.save > /dev/null; then
  551.     AC_DEFINE(O_SAVE)
  552.     O_SAVE=yes
  553.     AC_MSG_RESULT(yes)
  554. else
  555.     AC_MSG_RESULT(no)
  556. fi
  557. rm -fr conftest*
  558.  
  559. if test "$O_SAVE" = "yes"; then
  560. dnl ****************************************************************
  561. dnl Configuring libraries/linking
  562. dnl Fixed by Horst von Brand <vonbrand@inf.utfsm.cl>
  563. dnl ****************************************************************
  564.  
  565. case "$host" in
  566.     *linux*)    STATICLIBS="/usr/lib/libc.a" ;;
  567.     *sunos5*)    STATICLIBS="/usr/lib/libc.a -ldl" ;;
  568.     *solaris2*)    STATICLIBS="/usr/lib/libc.a -ldl" ;;
  569.     *sunos4*)    if test "$ac_cv_func_dlopen" = "yes"; then
  570.            STATICLIBS="/usr/lib/libc.a"
  571.         else
  572.            LDFLAGS="$LDFLAGS -static"
  573.         fi ;;
  574.     *)
  575.     AC_CHECK_PROGS(LDD, ldd, "none")
  576.     if test "$LDD" = "ldd"; then
  577.     ac_old_libs="$LIBS"
  578.     ac_old_ldflags="$LDFLAGS"
  579.     LDFLAGS="$LDFLAGS -static"
  580.     AC_MSG_CHECKING("what kind of static linking is required")
  581.  
  582. AC_TRY_LINK(
  583. [],
  584. [
  585. #ifdef HAVE_DLOPEN
  586.   dlopen();
  587. #endif
  588. ], ldstatic=yes)
  589.  
  590.     if test "$ldstatic" != "yes"; then
  591.         LDFLAGS="$ac_old_ldflags"
  592.         STATICLIBS=/usr/lib/libc.a
  593.         AC_MSG_RESULT("LDFLAGS=$LDFLAGS and STATICLIBS=$STATICLIBS")
  594.         fi
  595.         AC_MSG_RESULT("LDFLAGS=$LDFLAGS")
  596.     fi ;;
  597. esac
  598. fi                    # O_SAVE's fi
  599. fi                    # "$configsave" = "yes"
  600.  
  601. if test "$configloadforeign" = "yes"; then
  602.  
  603. dnl ****************************************************************
  604. dnl Foreign language interface
  605. dnl ****************************************************************
  606.  
  607. AC_MSG_CHECKING("foreign C-interface")
  608. AC_TRY_COMPILE([
  609. #include <stdio.h>
  610. #include <sys/ldr.h>
  611. ],
  612. [ char *buf[10];
  613.   load("test", L_NOAUTODEFER, ".");
  614.   loadquery(L_GETMESSAGES, &buf[2], sizeof(buf) - 8);
  615. ], AC_DEFINE(O_AIX_FOREIGN)
  616.    AC_MSG_RESULT("AIX load based")
  617.    ac_foreign=yes
  618.    PLFOREIGN=aix_foreign.pl,
  619.    PLFOREIGN=foreign.pl)
  620.  
  621.  
  622. if test "$ac_foreign" != "yes"; then
  623. AC_TRY_COMPILE(
  624. [
  625. #include <rld.h>
  626. ],
  627. [ char *objfiles[10];
  628.   struct mach_header *m_header;
  629.   unsigned long rld_address;
  630.  
  631.   rld_load(stderr, &m_header, objfiles, NULL);
  632.   rld_lookup(NULL, "_init", &rld_address);
  633. ], AC_DEFINE(O_MACH_FOREIGN)
  634.    AC_MSG_RESULT("MACH rld_load based")
  635.    ac_foreign=yes)
  636. fi
  637.  
  638. dnl ****************************************************************
  639. dnl BSD Unix ld -A .../a.out format foreign interface
  640. dnl ****************************************************************
  641.  
  642. if test "$ac_foreign" != "yes"; then
  643. AC_MSG_RESULT("no OS supported incremental linking")
  644. AC_MSG_CHECKING("for ld -A")
  645. cat > conftest.c <<EOF
  646. int itf(){return 1;}
  647. int main(int argc, char **argv){ return 0; }
  648. EOF
  649. if eval $ac_link && test -s conftest; then
  650. cat > conftest-sub.c <<EOF
  651. int init(){return itf();}
  652. EOF
  653. if ${CC-cc} -c conftest-sub.c; then
  654. if ${CC-cc} -o conftest-sub -N -A conftest -T 10000 -lc 2>&5 && test -s conftest-sub 2>&5; then
  655.     AC_DEFINE(HAVE_LD_A)
  656.     AC_DEFINE_UNQUOTED(LD_COMMAND, "$CC")
  657.     AC_MSG_RESULT(yes)
  658. rm -rf conftest*
  659. AC_MSG_CHECKING("BSD a.out based loading")
  660. AC_TRY_COMPILE(
  661. [
  662. #include <stdio.h>
  663. #include <sys/types.h>
  664. #include <a.out.h>
  665. ],
  666. [
  667. ], AC_DEFINE(O_FOREIGN)
  668.    AC_MSG_RESULT(yes),
  669.    AC_MSG_RESULT(no))
  670. else
  671.    AC_MSG_RESULT(no)
  672. fi
  673. fi
  674. fi
  675. fi
  676. rm -rf conftest*
  677. fi # configloadforeign
  678.  
  679. AC_OUTPUT(Makefile README.bin pl.1)
  680.